#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
    int deleteGreatestValue(vector<vector<int>>& grid) {
        int row=grid.size();
        int col=grid[0].size();
        for(int i=0;i<row;i++)
        {
            sort(grid[i].begin(),grid[i].end());
        }
        int res=0;
        for(int j=0;j<col;j++)
        {
            int mx=0;
            for(int i=0;i<row;i++)
            {
                mx=max(mx,grid[i][j]);
            }
            res+=mx;

        }
        return res;
    }
};